<template>
  <div>
    <div class="games_wrap">
      <van-list finished-text="没有更多了">
        <van-empty
          v-if="list.length === 0"
          image="search"
          description="暂无对应社团的审核"
        />
        <van-cell v-for="(item, index) in list" :key="index">
          <div class="games_item">
            <div class="left">
              <div class="icon">
                <img :src="imgUrl + item.icon" alt="" />
              </div>
              <div class="center">
                <div class="name">{{ item.organization_name }}</div>
                <div class="information">
                  申请状态：{{ statusList[item.status] }}
                </div>
                <div class="information">
                  <van-icon name="contact" />申请者ID：{{ item.uid }}
                </div>
              </div>
            </div>
            <div class="download">
              <div class="graph" @click="handleDetail(item.id, 1)">
                {{ item.status == 0 ? "审核通过" : statusList[item.status] }}
              </div>
              <div
                class="graph"
                @click="handleDetail(item.id, 2)"
                v-if="item.status == 0"
              >
                {{ item.status == 0 ? "拒绝通过" : "" }}
              </div>
            </div>
          </div>
        </van-cell>
      </van-list>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default: Array
    }
  },
  data() {
    return {
      // loading: false,
      // finished: false
      imgUrl: process.env.VUE_APP_IMG_URL,
      statusList: ["未审核", "已通过", "已拒绝"]
    };
  },
  methods: {
    getGamesList() {
      console.log(1);
    },
    async handleDetail(id, status) {
      await this.$http.setOrganizationAuditById({
        id,
        status
      });
      this.$toast.success("用户审核成功！");
      this.$emit("fetch");
      // location.reload()
    }
  }
};
</script>

<style lang="scss" scoped>
.games_wrap {
  .games_item {
    position: relative;
    padding: 0.1rem 0;
    display: flex;
    align-items: center;
    .left {
      display: flex;
      flex: 1;
      .icon {
        width: 1.5rem;
        height: 1.5rem;
        border-radius: 0.3rem;
        border: 1px solid #ccc;
        img {
          width: 100%;
          height: 100%;
          border-radius: 0.2rem;
        }
      }
      .center {
        display: flex;
        flex-direction: column;
        margin-left: 0.5rem;
        margin-right: 0.1rem;
        .name {
          flex: 1;
          font-size: 0.4rem;
        }
        .information {
          font-size: 0.2rem;
          display: flex;
          align-items: center;
          flex-wrap: wrap;
        }
      }
    }
    .download {
      display: flex;
      flex-direction: column;
      .graph {
        margin: 0.1rem 0;
        z-index: 0;
        width: 1.8rem;
        height: 0.8rem;
        background-color: #00d09e;
        border-radius: 0.1rem;
        color: #fff;
        font-size: 0.35rem;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
  }
}
</style>
